﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Database;
public partial class admin_SuaNSX : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        var pm = new checkLogin();
        pm.redirectToLoginPage();
            if (!IsPostBack)
            {
                if (Session["tenkh"] == "Admin")
                {
                    Response.Redirect("Login.aspx");
                }
                else
                {
                    XuLyXuat();
                }
            }

        }
        public void XuLyXuat()
        {
            int mahangsx = int.Parse(Request.QueryString["mahangsx"].ToString());

            HangSX hsx = new HangSX();
            hsx = hsx.ThongTinHSX(mahangsx);
            this.txtMaHangSX.Text = hsx.Mahangsx.ToString();
            this.txtTenHangSX.Text = hsx.Tenhang;
            this.txtQuocGia.Text = hsx.Quocgia;
            this.txtLienHe.Text = hsx.Lienhe;            

        }
        protected void btSave_Click(object sender, EventArgs e)
        {
            int mahangsx = int.Parse(txtMaHangSX.Text);
            string logo = UpLoadLogo.FileName.ToString();
            HangSX hsx = new HangSX();
            hsx.CapNhatNSX(mahangsx, this.txtTenHangSX.Text, this.txtQuocGia.Text, this.txtLienHe.Text, logo);
            Response.Redirect("HienThiHSX.aspx");
        }

        protected void btCancel_Click(object sender, EventArgs e)
        {
            txtTenHangSX.Text = "";
            txtQuocGia.Text = "";
            txtLienHe.Text = "";
        }
    
}
